const {Menu, BrowserWindow} = require("electron");

let template = [{
    label: "文件",
    submenu: [{
        label: "打开文件",
        click() {
            console.log("打开文件")
        }
    }, {
        label: "打开文件夹",
        click() {
            console.log("打开文件夹")
        }
    }, {
        label: "打开百度",
        accelerator: "Ctrl+D",
        click() {
            let newWin = new BrowserWindow({
                width: 400,
                height: 400
            });
            newWin.loadURL("https://www.baidu.com");
            newWin.on('closed', () => {
                newWin = null;
            })
        }
    }]
}, {
    label: "编辑"
}];
let menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);